package com.sxtyxt.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.sxtyxt.online.App;

/**
 * 网络相关
 * Created by General on 15/8/17.
 */
public class NetUtils {

    /**
     * 判断网络是否可用
     *
     * @return
     */
    public static boolean isNetworkConnected() {
        Context context = App.getInstance().getApplicationContext();
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
            if (mNetworkInfo != null) {
                return mNetworkInfo.isAvailable();
            }
        }
        return false;
    }
}
